const TokenKey = 'H5-Token'

export function getToken() {
	return uni.getStorageSync(TokenKey)
}

export function setToken(token) {
	return uni.setStorageSync(TokenKey, token)
}

export function removeToken() {
	return uni.removeStorage(TokenKey)
}

/**
 * 判断用户是否已经登录
 */
export const isLogin = (that) => {
	const token = getToken();
	if (!token || token.length < 30) {
		uni.showModal({
			title: "用户未登录",
			confirmText:"去登录",
			confirmColor:"#e8380d",
			showCancel:false,
			success: function () {
				uni.navigateTo({
					url: '../login/login',
				});
			}
		})
		return false;
	} else {
		return true;
	}
}
